package com.howtographql.hackernews.vote;

/**
 * 功能说明：
 *
 * @author xiaoyu
 * @date 2019/2/21
 */

import com.coxautodev.graphql.tools.GraphQLResolver;
import com.howtographql.hackernews.link.Link;
import com.howtographql.hackernews.link.LinkRepository;
import com.howtographql.hackernews.user.User;
import com.howtographql.hackernews.user.UserRepository;

/**
 *
 * @description
 * @version 1.0
 * @author Administrator
 * @date 2019/2/21 15:53
 *
 */
public class VoteResolver implements GraphQLResolver<Vote> {
    private final LinkRepository linkRepository;
    private final UserRepository userRepository;

    public VoteResolver(LinkRepository linkRepository, UserRepository userRepository) {
        this.linkRepository = linkRepository;
        this.userRepository = userRepository;
    }

    public User user(Vote vote) {
        return userRepository.findById(vote.getUserId());
    }

    public Link link(Vote vote) {
        return linkRepository.findById(vote.getLinkId());
    }

}
